home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue27 / clinic / LISTING1.PAS next >
Encoding:
Pascal/Delphi Source File  |  1997-10-15  |  582 b   |  22 lines

  1. function DiskFree(Drive: Byte): Single;
  2. var
  3.   RootPath: array[0..4] of Char;
  4.   RootPtr: PChar;
  5.   SectorsPerCluster, BytesPerSector,
  6.   FreeClusters, TotalClusters: Integer;
  7.   SPC: Single;
  8. begin
  9.   RootPtr := nil;
  10.   if Drive > 0 then begin
  11.     StrCopy(RootPath, æA:\Æ);
  12.     RootPath[0] := Char(Drive + $40);
  13.     RootPtr := RootPath;
  14.   end;
  15.   if GetDiskFreeSpace(RootPtr, SectorsPerCluster, BytesPerSector,
  16.     FreeClusters, TotalClusters) then begin
  17.     SPC := SectorsPerCluster;
  18.     Result := SPC * BytesPerSector * FreeClusters
  19.   end else
  20.     Result := -1;
  21. end;
  22.